<?php
require 'config.php';
$user_id = $_REQUEST['user_id'];
$user_name = $_REQUEST['user_name'];
$user_mobile = $_REQUEST['user_mobile'];
// $address1 = $_REQUEST['address1'];
// $address2 = $_REQUEST['address2'];
// $address3 = $_REQUEST['address3'];
//$address4=$_REQUEST['address4'];
$address4 = 0;
$address = $_REQUEST['address'];
$number = $_REQUEST['number'];
$lat = $_REQUEST['lat'];
$lng = $_REQUEST['lng'];
$time = date('Y-m-d H:i:s');
$sql = "select * from `" . $oto . "_user_address` where `userId`='" . $user_id . "'";

$result = $db->query($sql);
while ($row = $result->fetch_assoc()) {
    $user_address[] = $row; //将取得的所有数据赋值给person_info数组
}
if (!isset($user_address)) {
    $isDefault = 1;
} else {
    $isDefault = 0;
}
$sql = "INSERT INTO `" . $oto . "_user_address` ( `userId`, `userName`, `userPhone`, `userTel`, `areaId1`, `areaId2`, `areaId3`, `communityId`, `address`, `postCode`, `isDefault`, `addressFlag`, `createTime`, `sex`, `lng`, `lat`, `number`) VALUES ( '{$user_id}', '{$user_name}', '{$user_mobile}', NULL, '0', '0', '0', '0', '{$address}', NULL, '{$isDefault}', '1', '{$time}', '0', '{$lng}', '{$lat}', '{$number}');";
if($db->query($sql)){
	echo 'true';
}else{
	echo 'fail';
}
//echo json_encode($result2);
